// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST_PAGE = "/${moduleFolder}/${className?uncap_first}/listPage",
  <#if tableTemplate == "tree">
  LIST = "/${moduleFolder}/${className?uncap_first}/list",
  CASCADER_LIST = "/${moduleFolder}/${className?uncap_first}/cascaderList",
  </#if>
  GET_BY_ID = "/${moduleFolder}/${className?uncap_first}/getById",
  ADD = "/${moduleFolder}/${className?uncap_first}/add",
  UPDATE = "/${moduleFolder}/${className?uncap_first}/update",
  DELETE = "/${moduleFolder}/${className?uncap_first}/deleteById",
  BATCH_DELETE = "/${moduleFolder}/${className?uncap_first}/batchDelete"
}

// 多条件分页查询
export const listPage = (params: any) => {
  return koi.get(API.LIST_PAGE, params);
};

<#if tableTemplate == "tree">
// 列表查询
export const list = (params: any) => {
  return koi.get(API.LIST, params);
};

// 级联下拉框
export const cascaderList = () => {
  return koi.get(API.CASCADER_LIST);
};

</#if>
// 根据ID进行查询
export const getById = (id: any) => {
  return koi.get(API.GET_BY_ID + "/" + id);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 删除
export const deleteById = (id: any) => {
  return koi.post(API.DELETE + "/" + id);
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, ids);
};

